home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: LaTeX Document
(document/latex).
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| LaTeX Document (document/latex)
| magic
| Supported |
1%
| dexvert
| NWiper Show (other/nWiperShow)
| ext
| Unsupported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| ASCII text, with CR line terminators
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| fmt/281 LaTeX (Subdocument)
| default
| |
100%
| detectItEasy
| Format: plain text[CR]
| default (weak)
|
|
id metadata |
---|
key | value |
---|
macFileType | [TEXT] |
macFileCreator | [MPS ] |
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 25 20 43 6f 70 79 72 69 | 67 68 74 20 31 39 39 31 |% Copyri|ght 1991|
|00000010| 20 62 79 20 4e 6f 72 6d | 61 6e 20 52 61 6d 73 65 | by Norm|an Ramse|
|00000020| 79 2e 20 20 41 6c 6c 20 | 72 69 67 68 74 73 20 72 |y. All |rights r|
|00000030| 65 73 65 72 76 65 64 2e | 0d 25 20 53 65 65 20 66 |eserved.|.% See f|
|00000040| 69 6c 65 20 43 4f 50 59 | 52 49 47 48 54 20 66 6f |ile COPY|RIGHT fo|
|00000050| 72 20 6d 6f 72 65 20 69 | 6e 66 6f 72 6d 61 74 69 |r more i|nformati|
|00000060| 6f 6e 2e 0d 40 20 0d 5c | 73 75 62 73 65 63 74 69 |on..@ .\|subsecti|
|00000070| 6f 6e 7b 54 68 65 20 69 | 6e 74 65 72 6e 61 6c 20 |on{The i|nternal |
|00000080| 73 74 72 75 63 74 75 72 | 65 20 6f 66 20 6d 6f 64 |structur|e of mod|
|00000090| 75 6c 65 73 20 28 63 68 | 75 6e 6b 73 29 7d 0d 54 |ules (ch|unks)}.T|
|000000a0| 68 69 73 20 63 6f 64 65 | 20 69 73 20 73 6f 20 6f |his code| is so o|
|000000b0| 6c 64 2c 20 69 74 20 64 | 61 74 65 73 20 62 61 63 |ld, it d|ates bac|
|000000c0| 6b 20 74 6f 20 77 68 65 | 6e 20 49 20 75 73 65 64 |k to whe|n I used|
|000000d0| 20 74 6f 20 63 61 6c 6c | 20 60 60 63 68 75 6e 6b | to call| ``chunk|
|000000e0| 73 27 27 20 60 60 6d 6f | 64 75 6c 65 73 2e 27 27 |s'' ``mo|dules.''|
|000000f0| 0d 40 0d 5c 73 75 62 73 | 75 62 73 65 63 74 69 6f |.@.\subs|ubsectio|
|00000100| 6e 7b 41 73 73 65 6d 62 | 6c 69 6e 67 20 6d 6f 64 |n{Assemb|ling mod|
|00000110| 75 6c 65 73 20 66 72 6f | 6d 20 70 61 72 74 73 7d |ules fro|m parts}|
|00000120| 0d 4d 6f 64 75 6c 65 73 | 20 61 72 65 20 6c 69 6e |.Modules| are lin|
|00000130| 6b 65 64 20 6c 69 73 74 | 73 2e 0d 45 61 63 68 20 |ked list|s..Each |
|00000140| 65 6c 65 6d 65 6e 74 20 | 6f 66 20 74 68 65 20 6c |element |of the l|
|00000150| 69 73 74 20 69 73 20 65 | 69 74 68 65 72 20 61 20 |ist is e|ither a |
|00000160| 73 74 72 69 6e 67 20 6f | 72 20 61 20 72 65 66 65 |string o|r a refe|
|00000170| 72 65 6e 63 65 20 74 6f | 20 61 6e 6f 74 68 65 72 |rence to| another|
|00000180| 20 0d 6d 6f 64 75 6c 65 | 20 6e 61 6d 65 2e 0d 44 | .module| name..D|
|00000190| 75 72 69 6e 67 20 65 78 | 70 61 6e 73 69 6f 6e 20 |uring ex|pansion |
|000001a0| 6f 66 20 61 20 6d 6f 64 | 75 6c 65 2c 20 73 74 72 |of a mod|ule, str|
|000001b0| 69 6e 67 73 20 61 72 65 | 20 70 72 69 6e 74 65 64 |ings are| printed|
|000001c0| 20 61 6e 64 20 6d 6f 64 | 75 6c 65 20 72 65 66 65 | and mod|ule refe|
|000001d0| 72 65 6e 63 65 73 0d 61 | 72 65 20 65 78 70 61 6e |rences.a|re expan|
|000001e0| 64 65 64 2e 0d 54 68 65 | 20 73 74 72 75 63 74 75 |ded..The| structu|
|000001f0| 72 65 20 6f 66 20 6d 6f | 64 75 6c 65 20 72 65 66 |re of mo|dule ref|
|00000200| 65 72 65 6e 63 65 73 20 | 6d 75 73 74 20 62 65 20 |erences |must be |
|00000210| 61 20 64 61 67 20 6f 72 | 20 65 6c 73 65 20 5b 5b |a dag or| else [[|
|00000220| 65 78 70 61 6e 64 5d 5d | 20 77 69 6c 6c 0d 63 6f |expand]]| will.co|
|00000230| 6d 70 6c 61 69 6e 20 61 | 62 6f 75 74 20 61 20 63 |mplain a|bout a c|
|00000240| 79 63 6c 65 2e 0d 3c 3c | 68 65 61 64 65 72 3e 3e |ycle..<<|header>>|
|00000250| 3d 0d 74 79 70 65 64 65 | 66 20 73 74 72 75 63 74 |=.typede|f struct|
|00000260| 20 6c 6f 63 61 74 69 6f | 6e 20 7b 20 20 20 20 20 | locatio|n { |
|00000270| 20 20 2f 2a 20 69 64 65 | 6e 74 69 66 79 20 6c 69 | /* ide|ntify li|
|00000280| 6e 65 73 20 6f 66 20 73 | 6f 75 72 63 65 20 2a 2f |nes of s|ource */|
|00000290| 0d 20 20 20 20 63 68 61 | 72 20 2a 66 69 6c 65 6e |. cha|r *filen|
|000002a0| 61 6d 65 3b 0d 20 20 20 | 20 69 6e 74 20 6c 69 6e |ame;. | int lin|
|000002b0| 65 6e 6f 3b 0d 7d 20 4c | 6f 63 61 74 69 6f 6e 3b |eno;.} L|ocation;|
|000002c0| 0d 0d 74 79 70 65 64 65 | 66 20 65 6e 75 6d 20 70 |..typede|f enum p|
|000002d0| 61 72 74 74 79 70 65 20 | 7b 53 54 52 49 4e 47 3d |arttype |{STRING=|
|000002e0| 31 2c 20 4d 4f 44 55 4c | 45 2c 20 4e 45 57 4c 49 |1, MODUL|E, NEWLI|
|000002f0| 4e 45 7d 20 50 61 72 74 | 74 79 70 65 3b 0d 0d 73 |NE} Part|type;..s|
|00000300| 74 72 75 63 74 20 6d 6f | 64 70 61 72 74 20 7b 0d |truct mo|dpart {.|
|00000310| 20 20 20 20 50 61 72 74 | 74 79 70 65 20 70 74 79 | Part|type pty|
|00000320| 70 65 3b 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |pe; | |
|00000330| 2f 2a 20 74 79 70 65 20 | 6f 66 20 66 72 61 67 6d |/* type |of fragm|
|00000340| 65 6e 74 3a 20 53 54 52 | 49 4e 47 2c 20 4d 4f 44 |ent: STR|ING, MOD|
|00000350| 55 4c 45 2c 20 4e 45 57 | 4c 49 4e 45 20 2a 2f 0d |ULE, NEW|LINE */.|
|00000360| 20 20 20 20 63 68 61 72 | 20 2a 63 6f 6e 74 65 6e | char| *conten|
|00000370| 74 73 3b 0d 20 20 20 20 | 4c 6f 63 61 74 69 6f 6e |ts;. |Location|
|00000380| 20 6c 6f 63 3b 20 20 20 | 20 20 20 20 20 20 20 20 | loc; | |
|00000390| 20 20 20 20 2f 2a 20 66 | 6f 72 20 53 74 72 69 6e | /* f|or Strin|
|000003a0| 67 2c 20 77 68 65 72 65 | 27 73 20 69 74 20 66 72 |g, where|'s it fr|
|000003b0| 6f 6d 20 3f 20 2a 2f 0d | 20 20 20 20 73 74 72 75 |om ? */.| stru|
|000003c0| 63 74 20 6d 6f 64 70 61 | 72 74 20 2a 6e 65 78 74 |ct modpa|rt *next|
|000003d0| 3b 0d 7d 3b 0d 40 20 25 | 64 65 66 20 4c 6f 63 61 |;.};.@ %|def Loca|
|000003e0| 74 69 6f 6e 20 70 61 72 | 74 74 79 70 65 20 6d 6f |tion par|ttype mo|
|000003f0| 64 70 61 72 74 0d 49 6e | 20 6f 72 64 65 72 20 74 |dpart.In| order t|
|00000400| 6f 20 66 61 63 69 6c 69 | 74 61 74 65 20 65 78 70 |o facili|tate exp|
|00000410| 61 6e 73 69 6f 6e 20 6f | 66 20 61 6c 6c 20 72 6f |ansion o|f all ro|
|00000420| 6f 74 73 20 28 61 6e 64 | 20 74 6f 20 69 64 65 6e |ots (and| to iden|
|00000430| 74 69 66 79 20 72 6f 6f | 74 73 29 2c 20 0d 49 20 |tify roo|ts), .I |
|00000440| 6b 65 65 70 20 61 20 75 | 73 65 20 63 6f 75 6e 74 |keep a u|se count|
|00000450| 65 72 20 69 6e 20 65 61 | 63 68 20 6d 6f 64 75 6c |er in ea|ch modul|
|00000460| 65 2e 0d 3c 3c 68 65 61 | 64 65 72 3e 3e 3d 0d 74 |e..<<hea|der>>=.t|
|00000470| 79 70 65 64 65 66 20 73 | 74 72 75 63 74 20 6d 6f |ypedef s|truct mo|
|00000480| 64 75 6c 65 20 7b 0d 20 | 20 20 20 63 68 61 72 20 |dule {. | char |
|00000490| 2a 6e 61 6d 65 3b 0d 20 | 20 20 20 69 6e 74 20 75 |*name;. | int u|
|000004a0| 73 65 63 6f 75 6e 74 3b | 0d 20 20 20 20 73 74 72 |secount;|. str|
|000004b0| 75 63 74 20 6d 6f 64 70 | 61 72 74 20 2a 68 65 61 |uct modp|art *hea|
|000004c0| 64 2c 20 2a 74 61 69 6c | 3b 0d 7d 20 2a 4d 6f 64 |d, *tail|;.} *Mod|
|000004d0| 75 6c 65 3b 0d 40 20 25 | 64 65 66 20 6d 6f 64 75 |ule;.@ %|def modu|
|000004e0| 6c 65 20 4d 6f 64 75 6c | 65 0d 3c 3c 68 65 61 64 |le Modul|e.<<head|
|000004f0| 65 72 3e 3e 3d 0d 4d 6f | 64 75 6c 65 20 6e 65 77 |er>>=.Mo|dule new|
|00000500| 6d 6f 64 75 6c 65 28 63 | 68 61 72 20 2a 6d 6f 64 |module(c|har *mod|
|00000510| 6e 61 6d 65 29 3b 20 20 | 20 20 20 20 20 20 20 2f |name); | /|
|00000520| 2a 20 63 72 65 61 74 65 | 20 61 20 6e 65 77 2c 20 |* create| a new, |
|00000530| 62 6c 61 6e 6b 20 6d 6f | 64 75 6c 65 20 2a 2f 0d |blank mo|dule */.|
|00000540| 3c 3c 43 20 66 75 6e 63 | 74 69 6f 6e 73 3e 3e 3d |<<C func|tions>>=|
|00000550| 0d 4d 6f 64 75 6c 65 20 | 6e 65 77 6d 6f 64 75 6c |.Module |newmodul|
|00000560| 65 20 28 63 68 61 72 20 | 2a 6d 6f 64 6e 61 6d 65 |e (char |*modname|
|00000570| 29 20 7b 0d 20 20 20 20 | 4d 6f 64 75 6c 65 20 70 |) {. |Module p|
|00000580| 20 3d 20 28 4d 6f 64 75 | 6c 65 29 20 6d 61 6c 6c | = (Modu|le) mall|
|00000590| 6f 63 20 28 73 69 7a 65 | 6f 66 20 28 73 74 72 75 |oc (size|of (stru|
|000005a0| 63 74 20 6d 6f 64 75 6c | 65 29 29 3b 0d 20 20 20 |ct modul|e));. |
|000005b0| 20 63 68 65 63 6b 70 74 | 72 28 70 29 3b 0d 20 20 | checkpt|r(p);. |
|000005c0| 20 20 70 2d 3e 6e 61 6d | 65 20 3d 20 73 74 72 73 | p->nam|e = strs|
|000005d0| 61 76 65 28 6d 6f 64 6e | 61 6d 65 29 3b 0d 20 20 |ave(modn|ame);. |
|000005e0| 20 20 70 2d 3e 75 73 65 | 63 6f 75 6e 74 20 3d 20 | p->use|count = |
|000005f0| 30 3b 0d 20 20 20 20 70 | 2d 3e 68 65 61 64 20 3d |0;. p|->head =|
|00000600| 20 70 2d 3e 74 61 69 6c | 20 3d 20 4e 55 4c 4c 3b | p->tail| = NULL;|
|00000610| 0d 20 20 20 20 72 65 74 | 75 72 6e 20 70 3b 0d 7d |. ret|urn p;.}|
|00000620| 0d 40 20 25 64 65 66 20 | 6e 65 77 6d 6f 64 75 6c |.@ %def |newmodul|
|00000630| 65 0d 3c 3c 2a 3e 3e 3d | 0d 23 69 6e 63 6c 75 64 |e.<<*>>=|.#includ|
|00000640| 65 20 3c 73 74 64 69 6f | 2e 68 3e 0d 23 69 6e 63 |e <stdio|.h>.#inc|
|00000650| 6c 75 64 65 20 3c 73 74 | 72 69 6e 67 2e 68 3e 0d |lude <st|ring.h>.|
|00000660| 23 69 6e 63 6c 75 64 65 | 20 3c 73 74 64 6c 69 62 |#include| <stdlib|
|00000670| 2e 68 3e 0d 23 69 6e 63 | 6c 75 64 65 20 3c 63 74 |.h>.#inc|lude <ct|
|00000680| 79 70 65 2e 68 3e 0d 23 | 69 6e 63 6c 75 64 65 20 |ype.h>.#|include |
|00000690| 22 6d 6f 64 75 6c 65 73 | 2e 68 22 0d 23 69 6e 63 |"modules|.h".#inc|
|000006a0| 6c 75 64 65 20 22 6d 6f | 64 74 72 65 65 73 2e 68 |lude "mo|dtrees.h|
|000006b0| 22 0d 23 69 6e 63 6c 75 | 64 65 20 22 65 72 72 6f |".#inclu|de "erro|
|000006c0| 72 73 2e 68 22 0d 23 69 | 6e 63 6c 75 64 65 20 22 |rs.h".#i|nclude "|
|000006d0| 63 6f 6c 75 6d 6e 73 2e | 68 22 0d 23 69 6e 63 6c |columns.|h".#incl|
|000006e0| 75 64 65 20 22 73 74 72 | 73 61 76 65 2e 68 22 0d |ude "str|save.h".|
|000006f0| 0d 3c 3c 46 75 6e 63 74 | 69 6f 6e 20 64 65 63 6c |.<<Funct|ion decl|
|00000700| 61 72 61 74 69 6f 6e 73 | 3e 3e 0d 3c 3c 6c 6f 63 |arations|>>.<<loc|
|00000710| 61 6c 20 64 61 74 61 3e | 3e 0d 3c 3c 43 20 66 75 |al data>|>.<<C fu|
|00000720| 6e 63 74 69 6f 6e 73 3e | 3e 0d 40 0d 3c 3c 68 65 |nctions>|>.@.<<he|
|00000730| 61 64 65 72 3e 3e 3d 0d | 23 64 65 66 69 6e 65 20 |ader>>=.|#define |
|00000740| 61 64 64 73 74 72 69 6e | 67 28 4d 50 2c 53 2c 4c |addstrin|g(MP,S,L|
|00000750| 29 20 61 64 64 5f 70 61 | 72 74 28 4d 50 2c 53 2c |) add_pa|rt(MP,S,|
|00000760| 53 54 52 49 4e 47 2c 26 | 4c 29 0d 20 20 20 20 20 |STRING,&|L). |
|00000770| 20 20 20 2f 2a 20 61 64 | 64 20 61 20 73 74 72 69 | /* ad|d a stri|
|00000780| 6e 67 20 74 6f 20 61 20 | 6d 6f 64 75 6c 65 20 64 |ng to a |module d|
|00000790| 65 66 69 6e 69 74 69 6f | 6e 20 28 73 74 72 69 70 |efinitio|n (strip|
|000007a0| 70 69 6e 67 20 66 69 6e | 61 6c 20 6e 65 77 6c 69 |ping fin|al newli|
|000007b0| 6e 65 29 20 2a 2f 0d 23 | 64 65 66 69 6e 65 20 61 |ne) */.#|define a|
|000007c0| 64 64 6d 6f 64 75 6c 65 | 28 4d 50 2c 53 29 20 61 |ddmodule|(MP,S) a|
|000007d0| 64 64 5f 70 61 72 74 28 | 4d 50 2c 53 2c 4d 4f 44 |dd_part(|MP,S,MOD|
|000007e0| 55 4c 45 2c 30 29 0d 20 | 20 20 20 20 20 20 20 2f |ULE,0). | /|
|000007f0| 2a 20 61 64 64 20 61 20 | 6d 6f 64 75 6c 65 20 72 |* add a |module r|
|00000800| 65 66 65 72 65 6e 63 65 | 20 74 6f 20 61 20 6d 6f |eference| to a mo|
|00000810| 64 75 6c 65 20 64 65 66 | 69 6e 69 74 69 6f 6e 20 |dule def|inition |
|00000820| 28 73 74 72 69 70 70 69 | 6e 67 20 66 69 6e 61 6c |(strippi|ng final|
|00000830| 20 6e 65 77 6c 69 6e 65 | 29 20 2a 2f 0d 23 64 65 | newline|) */.#de|
|00000840| 66 69 6e 65 20 61 64 64 | 6e 65 77 6c 69 6e 65 28 |fine add|newline(|
|00000850| 4d 50 29 20 61 64 64 5f | 70 61 72 74 28 4d 50 2c |MP) add_|part(MP,|
|00000860| 30 2c 4e 45 57 4c 49 4e | 45 2c 30 29 0d 76 6f 69 |0,NEWLIN|E,0).voi|
|00000870| 64 20 61 64 64 5f 70 61 | 72 74 20 28 4d 6f 64 75 |d add_pa|rt (Modu|
|00000880| 6c 65 20 6d 70 2c 20 63 | 68 61 72 20 2a 73 2c 20 |le mp, c|har *s, |
|00000890| 50 61 72 74 74 79 70 65 | 20 74 79 70 65 2c 20 4c |Parttype| type, L|
|000008a0| 6f 63 61 74 69 6f 6e 20 | 2a 6c 6f 63 29 3b 0d 40 |ocation |*loc);.@|
|000008b0| 20 25 64 65 66 20 61 64 | 64 73 74 72 69 6e 67 20 | %def ad|dstring |
|000008c0| 61 64 64 6d 6f 64 75 6c | 65 20 61 64 64 6e 65 77 |addmodul|e addnew|
|000008d0| 6c 69 6e 65 0d 3c 3c 43 | 20 66 75 6e 63 74 69 6f |line.<<C| functio|
|000008e0| 6e 73 3e 3e 3d 0d 76 6f | 69 64 20 61 64 64 5f 70 |ns>>=.vo|id add_p|
|000008f0| 61 72 74 20 28 4d 6f 64 | 75 6c 65 20 6d 70 2c 20 |art (Mod|ule mp, |
|00000900| 63 68 61 72 20 2a 73 2c | 20 50 61 72 74 74 79 70 |char *s,| Parttyp|
|00000910| 65 20 74 79 70 65 2c 20 | 4c 6f 63 61 74 69 6f 6e |e type, |Location|
|00000920| 20 2a 6c 6f 63 29 20 7b | 0d 20 20 20 20 73 74 72 | *loc) {|. str|
|00000930| 75 63 74 20 6d 6f 64 70 | 61 72 74 20 2a 70 20 3d |uct modp|art *p =|
|00000940| 20 6e 65 77 6d 6f 64 70 | 61 72 74 28 74 79 70 65 | newmodp|art(type|
|00000950| 2c 73 2c 6c 6f 63 29 3b | 0d 20 20 20 20 61 70 70 |,s,loc);|. app|
|00000960| 65 6e 64 20 28 6d 70 2c | 70 29 3b 0d 7d 0d 40 20 |end (mp,|p);.}.@ |
|00000970| 25 64 65 66 20 61 64 64 | 5f 70 61 72 74 0d 3c 3c |%def add|_part.<<|
|00000980| 43 20 66 75 6e 63 74 69 | 6f 6e 73 3e 3e 3d 0d 73 |C functi|ons>>=.s|
|00000990| 74 61 74 69 63 20 73 74 | 72 75 63 74 20 6d 6f 64 |tatic st|ruct mod|
|000009a0| 70 61 72 74 20 2a 0d 6e | 65 77 6d 6f 64 70 61 72 |part *.n|ewmodpar|
|000009b0| 74 28 69 6e 74 20 74 79 | 70 65 2c 20 63 68 61 72 |t(int ty|pe, char|
|000009c0| 20 2a 73 2c 20 4c 6f 63 | 61 74 69 6f 6e 20 2a 6c | *s, Loc|ation *l|
|000009d0| 6f 63 29 20 7b 0d 20 20 | 20 20 73 74 72 75 63 74 |oc) {. | struct|
|000009e0| 20 6d 6f 64 70 61 72 74 | 20 2a 70 20 3d 20 28 73 | modpart| *p = (s|
|000009f0| 74 72 75 63 74 20 6d 6f | 64 70 61 72 74 20 2a 29 |truct mo|dpart *)|
|00000a00| 20 6d 61 6c 6c 6f 63 20 | 28 73 69 7a 65 6f 66 20 | malloc |(sizeof |
|00000a10| 28 73 74 72 75 63 74 20 | 6d 6f 64 70 61 72 74 29 |(struct |modpart)|
|00000a20| 29 3b 0d 20 20 20 20 63 | 68 65 63 6b 70 74 72 28 |);. c|heckptr(|
|00000a30| 70 29 3b 0d 20 20 20 20 | 70 2d 3e 70 74 79 70 65 |p);. |p->ptype|
|00000a40| 20 3d 20 74 79 70 65 3b | 0d 20 20 20 20 69 66 20 | = type;|. if |
|00000a50| 28 73 29 20 7b 0d 20 20 | 20 20 20 20 20 20 70 2d |(s) {. | p-|
|00000a60| 3e 63 6f 6e 74 65 6e 74 | 73 20 3d 20 73 74 72 73 |>content|s = strs|
|00000a70| 61 76 65 28 73 29 3b 0d | 20 20 20 20 20 20 20 20 |ave(s);.| |
|00000a80| 3c 3c 73 74 72 69 70 20 | 66 69 6e 61 6c 20 6e 65 |<<strip |final ne|
|00000a90| 77 6c 69 6e 65 20 66 72 | 6f 6d 20 70 2d 3e 63 6f |wline fr|om p->co|
|00000aa0| 6e 74 65 6e 74 73 3e 3e | 0d 20 20 20 20 7d 0d 20 |ntents>>|. }. |
|00000ab0| 20 20 20 69 66 20 28 6c | 6f 63 29 20 70 2d 3e 6c | if (l|oc) p->l|
|00000ac0| 6f 63 20 3d 20 2a 6c 6f | 63 3b 0d 20 20 20 20 70 |oc = *lo|c;. p|
|00000ad0| 2d 3e 6e 65 78 74 20 3d | 20 4e 55 4c 4c 3b 0d 20 |->next =| NULL;. |
|00000ae0| 20 20 20 72 65 74 75 72 | 6e 20 70 3b 0d 7d 0d 40 | retur|n p;.}.@|
|00000af0| 20 25 64 65 66 20 6e 65 | 77 6d 6f 64 70 61 72 74 | %def ne|wmodpart|
|00000b00| 0d 3c 3c 43 20 66 75 6e | 63 74 69 6f 6e 73 3e 3e |.<<C fun|ctions>>|
|00000b10| 3d 0d 73 74 61 74 69 63 | 0d 76 6f 69 64 20 61 70 |=.static|.void ap|
|00000b20| 70 65 6e 64 28 4d 6f 64 | 75 6c 65 20 6d 70 2c 20 |pend(Mod|ule mp, |
|00000b30| 73 74 72 75 63 74 20 6d | 6f 64 70 61 72 74 20 2a |struct m|odpart *|
|00000b40| 70 29 20 7b 0d 20 20 20 | 20 2f 2a 20 61 70 70 65 |p) {. | /* appe|
|00000b50| 6e 64 20 70 20 74 6f 20 | 6d 70 27 73 20 6c 69 73 |nd p to |mp's lis|
|00000b60| 74 20 6f 66 20 6d 6f 64 | 70 61 72 74 73 20 2a 2f |t of mod|parts */|
|00000b70| 0d 20 20 20 20 69 66 20 | 28 6d 70 2d 3e 68 65 61 |. if |(mp->hea|
|00000b80| 64 20 3d 3d 20 4e 55 4c | 4c 29 20 7b 0d 20 20 20 |d == NUL|L) {. |
|00000b90| 20 20 20 20 20 6d 70 2d | 3e 68 65 61 64 20 3d 20 | mp-|>head = |
|00000ba0| 6d 70 2d 3e 74 61 69 6c | 20 3d 20 70 3b 0d 20 20 |mp->tail| = p;. |
|00000bb0| 20 20 7d 20 65 6c 73 65 | 20 7b 0d 20 20 20 20 20 | } else| {. |
|00000bc0| 20 20 20 6d 70 2d 3e 74 | 61 69 6c 2d 3e 6e 65 78 | mp->t|ail->nex|
|00000bd0| 74 20 3d 20 70 3b 0d 20 | 20 20 20 20 20 20 20 6d |t = p;. | m|
|00000be0| 70 2d 3e 74 61 69 6c 20 | 3d 20 70 3b 0d 20 20 20 |p->tail |= p;. |
|00000bf0| 20 7d 0d 7d 0d 40 20 25 | 64 65 66 20 61 70 70 65 | }.}.@ %|def appe|
|00000c00| 6e 64 0d 3c 3c 73 74 72 | 69 70 20 66 69 6e 61 6c |nd.<<str|ip final|
|00000c10| 20 6e 65 77 6c 69 6e 65 | 20 66 72 6f 6d 20 70 2d | newline| from p-|
|00000c20| 3e 63 6f 6e 74 65 6e 74 | 73 3e 3e 3d 0d 7b 20 69 |>content|s>>=.{ i|
|00000c30| 6e 74 20 6b 20 3d 20 73 | 74 72 6c 65 6e 28 70 2d |nt k = s|trlen(p-|
|00000c40| 3e 63 6f 6e 74 65 6e 74 | 73 29 2d 31 3b 0d 20 20 |>content|s)-1;. |
|00000c50| 69 66 20 28 70 2d 3e 63 | 6f 6e 74 65 6e 74 73 5b |if (p->c|ontents[|
|00000c60| 6b 5d 20 3d 3d 20 27 5c | 6e 27 29 20 70 2d 3e 63 |k] == '\|n') p->c|
|00000c70| 6f 6e 74 65 6e 74 73 5b | 6b 5d 20 3d 20 27 5c 30 |ontents[|k] = '\0|
|00000c80| 27 3b 0d 20 20 65 6c 73 | 65 20 69 6d 70 6f 73 73 |';. els|e imposs|
|00000c90| 69 62 6c 65 28 22 69 6e | 70 75 74 20 6c 69 6e 65 |ible("in|put line|
|00000ca0| 20 64 6f 65 73 6e 27 74 | 20 65 6e 64 20 77 69 74 | doesn't| end wit|
|00000cb0| 68 20 6e 65 77 6c 69 6e | 65 22 29 3b 0d 7d 0d 40 |h newlin|e");.}.@|
|00000cc0| 0d 3c 3c 46 75 6e 63 74 | 69 6f 6e 20 64 65 63 6c |.<<Funct|ion decl|
|00000cd0| 61 72 61 74 69 6f 6e 73 | 3e 3e 3d 0d 73 74 61 74 |arations|>>=.stat|
|00000ce0| 69 63 20 73 74 72 75 63 | 74 20 6d 6f 64 70 61 72 |ic struc|t modpar|
|00000cf0| 74 20 2a 0d 6e 65 77 6d | 6f 64 70 61 72 74 28 69 |t *.newm|odpart(i|
|00000d00| 6e 74 20 74 79 70 65 2c | 20 63 68 61 72 20 2a 73 |nt type,| char *s|
|00000d10| 2c 20 4c 6f 63 61 74 69 | 6f 6e 20 2a 6c 6f 63 29 |, Locati|on *loc)|
|00000d20| 3b 20 20 20 2f 2a 20 63 | 72 65 61 74 65 20 61 20 |; /* c|reate a |
|00000d30| 6e 65 77 20 6d 6f 64 75 | 6c 65 20 70 61 72 74 20 |new modu|le part |
|00000d40| 2a 2f 0d 0d 73 74 61 74 | 69 63 0d 76 6f 69 64 20 |*/..stat|ic.void |
|00000d50| 61 70 70 65 6e 64 28 4d | 6f 64 75 6c 65 20 6d 70 |append(M|odule mp|
|00000d60| 2c 20 73 74 72 75 63 74 | 20 6d 6f 64 70 61 72 74 |, struct| modpart|
|00000d70| 20 2a 70 29 3b 0d 40 0d | 5c 73 75 62 73 75 62 73 | *p);.@.|\subsubs|
|00000d80| 65 63 74 69 6f 6e 7b 45 | 78 70 61 6e 64 69 6e 67 |ection{E|xpanding|
|00000d90| 20 6d 6f 64 75 6c 65 73 | 7d 0d 5b 5b 65 78 70 61 | modules|}.[[expa|
|00000da0| 6e 64 5d 5d 20 72 65 74 | 75 72 6e 73 20 30 20 69 |nd]] ret|urns 0 i|
|00000db0| 66 20 61 6c 6c 20 69 73 | 20 77 65 6c 6c 2c 20 6e |f all is| well, n|
|00000dc0| 6f 6e 7a 65 72 6f 20 69 | 66 20 65 72 72 6f 72 2e |onzero i|f error.|
|00000dd0| 0d 41 20 5b 5b 73 74 72 | 75 63 74 20 70 61 72 65 |.A [[str|uct pare|
|00000de0| 6e 74 5d 5d 20 63 68 61 | 69 6e 20 6c 69 73 74 73 |nt]] cha|in lists|
|00000df0| 20 6d 6f 64 75 6c 65 73 | 20 63 75 72 72 65 6e 74 | modules| current|
|00000e00| 6c 79 20 62 65 69 6e 67 | 20 65 78 70 61 6e 64 65 |ly being| expande|
|00000e10| 64 2c 20 0d 73 6f 20 49 | 20 63 61 6e 20 64 65 74 |d, .so I| can det|
|00000e20| 65 63 74 20 63 79 63 6c | 65 73 2e 0d 5b 5b 70 61 |ect cycl|es..[[pa|
|00000e30| 72 74 69 61 6c 5f 64 69 | 73 74 61 6e 63 65 5d 5d |rtial_di|stance]]|
|00000e40| 20 69 73 20 74 68 65 20 | 73 69 7a 65 20 6f 66 20 | is the |size of |
|00000e50| 74 68 65 20 6c 69 6e 65 | 20 61 6c 72 65 61 64 79 |the line| already|
|00000e60| 20 77 72 69 74 74 65 6e | 20 6f 75 74 20 77 68 65 | written| out whe|
|00000e70| 6e 0d 5b 5b 65 78 70 61 | 6e 64 5d 5d 20 69 73 20 |n.[[expa|nd]] is |
|00000e80| 63 61 6c 6c 65 64 2e 0d | 3c 3c 68 65 61 64 65 72 |called..|<<header|
|00000e90| 3e 3e 3d 0d 74 79 70 65 | 64 65 66 20 73 74 72 75 |>>=.type|def stru|
|00000ea0| 63 74 20 70 61 72 65 6e | 74 20 7b 0d 20 20 20 20 |ct paren|t {. |
|00000eb0| 4d 6f 64 75 6c 65 20 74 | 68 69 73 3b 0d 20 20 20 |Module t|his;. |
|00000ec0| 20 73 74 72 75 63 74 20 | 70 61 72 65 6e 74 20 2a | struct |parent *|
|00000ed0| 70 61 72 65 6e 74 3b 0d | 7d 20 2a 50 61 72 65 6e |parent;.|} *Paren|
|00000ee0| 74 3b 0d 0d 69 6e 74 20 | 65 78 70 61 6e 64 20 28 |t;..int |expand (|
|00000ef0| 4d 6f 64 75 6c 65 20 6d | 70 2c 20 69 6e 74 20 69 |Module m|p, int i|
|00000f00| 6e 64 65 6e 74 2c 20 69 | 6e 74 20 70 61 72 74 69 |ndent, i|nt parti|
|00000f10| 61 6c 5f 64 69 73 74 61 | 6e 63 65 2c 20 50 61 72 |al_dista|nce, Par|
|00000f20| 65 6e 74 20 70 61 72 65 | 6e 74 2c 20 0d 09 20 20 |ent pare|nt, .. |
|00000f30| 20 20 63 68 61 72 20 2a | 6c 6f 63 66 6f 72 6d 61 | char *|locforma|
|00000f40| 74 2c 20 46 49 4c 45 20 | 2a 6f 75 74 29 3b 0d 20 |t, FILE |*out);. |
|00000f50| 20 20 20 20 20 20 20 2f | 2a 20 65 78 70 61 6e 64 | /|* expand|
|00000f60| 20 61 20 6d 6f 64 75 6c | 65 2c 20 77 72 69 74 69 | a modul|e, writi|
|00000f70| 6e 67 20 74 6f 20 66 69 | 6c 65 20 6f 75 74 20 2a |ng to fi|le out *|
|00000f80| 2f 0d 40 20 25 64 65 66 | 20 50 61 72 65 6e 74 0d |/.@ %def| Parent.|
|00000f90| 3c 3c 6c 6f 63 61 6c 20 | 64 61 74 61 3e 3e 3d 0d |<<local |data>>=.|
|00000fa0| 73 74 61 74 69 63 20 63 | 68 61 72 20 2a 6c 61 73 |static c|har *las|
|00000fb0| 74 66 69 6c 65 6e 61 6d | 65 20 3d 20 30 3b 0d 73 |tfilenam|e = 0;.s|
|00000fc0| 74 61 74 69 63 20 69 6e | 74 20 6c 61 73 74 6c 69 |tatic in|t lastli|
|00000fd0| 6e 65 6e 6f 20 3d 20 2d | 31 3b 0d 40 20 25 64 65 |neno = -|1;.@ %de|
|00000fe0| 66 20 6c 61 73 74 66 69 | 6c 65 6e 61 6d 65 20 6c |f lastfi|lename l|
|00000ff0| 61 73 74 6c 69 6e 65 6e | 6f 0d 3c 3c 68 65 61 64 |astlinen|o.<<head|
|00001000| 65 72 3e 3e 3d 0d 76 6f | 69 64 20 72 65 73 65 74 |er>>=.vo|id reset|
|00001010| 6c 6f 63 28 76 6f 69 64 | 29 3b 0d 3c 3c 43 20 66 |loc(void|);.<<C f|
|00001020| 75 6e 63 74 69 6f 6e 73 | 3e 3e 3d 0d 76 6f 69 64 |unctions|>>=.void|
|00001030| 20 72 65 73 65 74 6c 6f | 63 28 76 6f 69 64 29 20 | resetlo|c(void) |
|00001040| 7b 0d 20 20 6c 61 73 74 | 66 69 6c 65 6e 61 6d 65 |{. last|filename|
|00001050| 20 3d 20 30 3b 0d 20 20 | 6c 61 73 74 6c 69 6e 65 | = 0;. |lastline|
|00001060| 6e 6f 20 3d 20 2d 31 3b | 0d 7d 0d 40 0d 5b 5b 69 |no = -1;|.}.@.[[i|
|00001070| 6e 64 65 6e 74 5d 5d 20 | 69 73 20 74 68 65 20 61 |ndent]] |is the a|
|00001080| 6d 6f 75 6e 74 20 62 79 | 20 77 68 69 63 68 20 74 |mount by| which t|
|00001090| 68 69 73 20 63 68 75 6e | 6b 20 73 68 6f 75 6c 64 |his chun|k should|
|000010a0| 20 62 65 20 69 6e 64 65 | 6e 74 65 64 2e 0d 5b 5b | be inde|nted..[[|
|000010b0| 70 61 72 74 69 61 6c 5f | 64 69 73 74 61 6e 63 65 |partial_|distance|
|000010c0| 5d 5d 20 69 73 20 74 68 | 65 20 77 69 64 74 68 20 |]] is th|e width |
|000010d0| 6f 66 20 77 68 61 74 20 | 68 61 73 20 61 6c 72 65 |of what |has alre|
|000010e0| 61 64 79 20 62 65 65 6e | 20 77 72 69 74 74 65 6e |ady been| written|
|000010f0| 20 74 6f 20 74 68 65 20 | 63 75 72 72 65 6e 74 20 | to the |current |
|00001100| 6c 69 6e 65 2e 0d 3c 3c | 43 20 66 75 6e 63 74 69 |line..<<|C functi|
|00001110| 6f 6e 73 3e 3e 3d 0d 69 | 6e 74 20 65 78 70 61 6e |ons>>=.i|nt expan|
|00001120| 64 20 28 4d 6f 64 75 6c | 65 20 6d 70 2c 20 69 6e |d (Modul|e mp, in|
|00001130| 74 20 69 6e 64 65 6e 74 | 2c 20 69 6e 74 20 70 61 |t indent|, int pa|
|00001140| 72 74 69 61 6c 5f 64 69 | 73 74 61 6e 63 65 2c 20 |rtial_di|stance, |
|00001150| 50 61 72 65 6e 74 20 70 | 61 72 65 6e 74 2c 20 20 |Parent p|arent, |
|00001160| 0d 20 20 20 20 20 20 20 | 20 20 20 20 20 63 68 61 |. | cha|
|00001170| 72 20 2a 6c 6f 63 66 6f | 72 6d 61 74 2c 20 46 49 |r *locfo|rmat, FI|
|00001180| 4c 45 20 2a 6f 75 74 29 | 20 7b 0d 20 20 20 20 73 |LE *out)| {. s|
|00001190| 74 72 75 63 74 20 6d 6f | 64 70 61 72 74 20 2a 70 |truct mo|dpart *p|
|000011a0| 3b 0d 20 20 20 20 4d 6f | 64 75 6c 65 20 6e 65 77 |;. Mo|dule new|
|000011b0| 6d 6f 64 3b 0d 20 20 20 | 20 69 6e 74 20 65 72 72 |mod;. | int err|
|000011c0| 6f 72 3d 4e 6f 72 6d 61 | 6c 3b 0d 20 20 20 20 73 |or=Norma|l;. s|
|000011d0| 74 72 75 63 74 20 70 61 | 72 65 6e 74 20 74 68 69 |truct pa|rent thi|
|000011e0| 73 6d 6f 64 75 6c 65 3b | 20 2f 2a 20 74 68 65 20 |smodule;| /* the |
|000011f0| 76 61 6c 75 65 20 6f 6e | 6c 79 20 6d 61 74 74 65 |value on|ly matte|
|00001200| 72 73 20 77 68 65 6e 20 | 77 65 27 72 65 20 65 78 |rs when |we're ex|
|00001210| 70 61 6e 64 69 6e 67 20 | 61 20 6d 6f 64 75 6c 65 |panding |a module|
|00001220| 20 2a 2f 0d 0d 20 20 20 | 20 3c 3c 73 65 74 20 5b | */.. | <<set [|
|00001230| 5b 74 68 69 73 6d 6f 64 | 75 6c 65 20 3d 20 7b 6d |[thismod|ule = {m|
|00001240| 70 2c 20 70 61 72 65 6e | 74 7d 5d 5d 3e 3e 0d 20 |p, paren|t}]]>>. |
|00001250| 20 20 20 3c 3c 69 66 20 | 5b 5b 6d 70 5d 5d 20 69 | <<if |[[mp]] i|
|00001260| 73 20 61 6e 20 61 6e 63 | 65 73 74 6f 72 2c 20 63 |s an anc|estor, c|
|00001270| 6f 6d 70 6c 61 69 6e 20 | 61 6e 64 20 72 65 74 75 |omplain |and retu|
|00001280| 72 6e 3e 3e 0d 0d 20 20 | 20 20 66 6f 72 20 28 70 |rn>>.. | for (p|
|00001290| 3d 6d 70 2d 3e 68 65 61 | 64 3b 20 70 21 3d 4e 55 |=mp->hea|d; p!=NU|
|000012a0| 4c 4c 3b 20 70 3d 70 2d | 3e 6e 65 78 74 29 20 7b |LL; p=p-|>next) {|
|000012b0| 0d 09 73 77 69 74 63 68 | 20 28 70 2d 3e 70 74 79 |..switch| (p->pty|
|000012c0| 70 65 29 20 7b 0d 09 20 | 20 20 20 63 61 73 65 20 |pe) {.. | case |
|000012d0| 53 54 52 49 4e 47 3a 20 | 20 3c 3c 70 72 69 6e 74 |STRING: | <<print|
|000012e0| 20 61 20 73 74 72 69 6e | 67 3e 3e 3b 20 20 62 72 | a strin|g>>; br|
|000012f0| 65 61 6b 3b 0d 09 20 20 | 20 20 63 61 73 65 20 4d |eak;.. | case M|
|00001300| 4f 44 55 4c 45 3a 20 20 | 3c 3c 65 78 70 61 6e 64 |ODULE: |<<expand|
|00001310| 20 61 20 6d 6f 64 75 6c | 65 3e 3e 3b 20 62 72 65 | a modul|e>>; bre|
|00001320| 61 6b 3b 0d 20 09 20 20 | 20 20 63 61 73 65 20 4e |ak;. . | case N|
|00001330| 45 57 4c 49 4e 45 3a 20 | 3c 3c 70 72 69 6e 74 20 |EWLINE: |<<print |
|00001340| 61 20 6e 65 77 6c 69 6e | 65 3e 3e 3b 20 62 72 65 |a newlin|e>>; bre|
|00001350| 61 6b 3b 0d 20 20 20 20 | 20 20 20 20 20 20 20 20 |ak;. | |
|00001360| 64 65 66 61 75 6c 74 3a | 20 69 6d 70 6f 73 73 69 |default:| impossi|
|00001370| 62 6c 65 28 22 62 61 64 | 20 70 61 72 74 20 74 79 |ble("bad| part ty|
|00001380| 70 65 22 29 3b 0d 20 20 | 20 20 20 20 20 20 7d 0d |pe");. | }.|
|00001390| 20 20 20 20 7d 0d 20 20 | 20 20 72 65 74 75 72 6e | }. | return|
|000013a0| 20 65 72 72 6f 72 3b 0d | 7d 0d 40 20 25 64 65 66 | error;.|}.@ %def|
|000013b0| 20 65 78 70 61 6e 64 0d | 3c 3c 73 65 74 20 5b 5b | expand.|<<set [[|
|000013c0| 74 68 69 73 6d 6f 64 75 | 6c 65 20 3d 20 7b 6d 70 |thismodu|le = {mp|
|000013d0| 2c 20 70 61 72 65 6e 74 | 7d 5d 5d 3e 3e 3d 0d 74 |, parent|}]]>>=.t|
|000013e0| 68 69 73 6d 6f 64 75 6c | 65 2e 74 68 69 73 20 3d |hismodul|e.this =|
|000013f0| 20 6d 70 3b 0d 74 68 69 | 73 6d 6f 64 75 6c 65 2e | mp;.thi|smodule.|
|00001400| 70 61 72 65 6e 74 20 3d | 20 70 61 72 65 6e 74 3b |parent =| parent;|
|00001410| 0d 40 0d 49 66 20 74 68 | 65 20 70 72 65 76 69 6f |.@.If th|e previo|
|00001420| 75 73 20 6c 69 6e 65 20 | 77 61 73 20 6e 6f 74 20 |us line |was not |
|00001430| 70 61 72 74 69 61 6c 2c | 20 74 68 69 73 20 73 74 |partial,| this st|
|00001440| 72 69 6e 67 20 73 74 61 | 72 74 73 20 61 20 66 72 |ring sta|rts a fr|
|00001450| 65 73 68 20 6c 69 6e 65 | 0d 61 6e 64 20 69 74 20 |esh line|.and it |
|00001460| 69 73 20 6e 65 63 65 73 | 73 61 72 79 20 74 6f 20 |is neces|sary to |
|00001470| 69 6e 64 65 6e 74 2e 0d | 57 68 65 6e 20 65 6d 69 |indent..|When emi|
|00001480| 74 74 69 6e 67 20 5b 5b | 23 6c 69 6e 65 5d 5d 20 |tting [[|#line]] |
|00001490| 64 69 72 65 63 74 69 76 | 65 73 2c 20 64 6f 6e 27 |directiv|es, don'|
|000014a0| 74 20 69 6e 64 65 6e 74 | 2d 2d 2d 69 6e 73 74 65 |t indent|---inste|
|000014b0| 61 64 20 74 72 79 20 74 | 6f 20 0d 70 72 65 73 65 |ad try t|o .prese|
|000014c0| 72 76 65 20 74 68 65 20 | 6f 72 69 67 69 6e 61 6c |rve the |original|
|000014d0| 20 63 6f 6c 75 6d 6e 20 | 6f 66 20 74 68 65 20 69 | column |of the i|
|000014e0| 6e 66 6f 72 6d 61 74 69 | 6f 6e 20 69 6e 20 74 68 |nformati|on in th|
|000014f0| 65 20 73 6f 75 72 63 65 | 2c 20 61 73 0d 77 65 6c |e source|, as.wel|
|00001500| 6c 20 61 73 20 74 68 65 | 20 6c 69 6e 65 20 6e 75 |l as the| line nu|
|00001510| 6d 62 65 72 2e 0d 54 68 | 69 73 20 6d 65 61 6e 73 |mber..Th|is means|
|00001520| 20 69 6e 64 65 6e 74 69 | 6e 67 20 62 79 20 5b 5b | indenti|ng by [[|
|00001530| 70 61 72 74 69 61 6c 5f | 64 69 73 74 61 6e 63 65 |partial_|distance|
|00001540| 5d 5d 20 69 66 20 61 20 | 5b 5b 23 6c 69 6e 65 5d |]] if a |[[#line]|
|00001550| 5d 20 64 69 72 65 63 74 | 69 76 65 20 0d 69 73 20 |] direct|ive .is |
|00001560| 65 6d 69 74 74 65 64 2c | 20 7b 5c 65 6d 20 65 78 |emitted,| {\em ex|
|00001570| 63 65 70 74 7d 20 77 68 | 65 6e 20 69 74 27 73 20 |cept} wh|en it's |
|00001580| 74 68 65 20 66 69 72 73 | 74 20 6c 69 6e 65 20 6f |the firs|t line o|
|00001590| 66 20 61 20 6d 6f 64 75 | 6c 65 20 28 68 61 63 6b |f a modu|le (hack|
|000015a0| 21 20 68 61 63 6b 21 29 | 2e 0d 5b 5b 70 72 69 6e |! hack!)|..[[prin|
|000015b0| 74 6c 6f 63 5d 5d 20 72 | 65 74 75 72 6e 73 20 6e |tloc]] r|eturns n|
|000015c0| 6f 6e 7a 65 72 6f 20 77 | 68 65 6e 20 5b 5b 23 6c |onzero w|hen [[#l|
|000015d0| 69 6e 65 5d 5d 20 69 73 | 20 61 63 74 75 61 6c 6c |ine]] is| actuall|
|000015e0| 79 20 65 6d 69 74 74 65 | 64 2e 0d 0d 3c 3c 70 72 |y emitte|d...<<pr|
|000015f0| 69 6e 74 20 61 20 73 74 | 72 69 6e 67 3e 3e 3d 0d |int a st|ring>>=.|
|00001600| 69 66 20 28 2a 28 70 2d | 3e 63 6f 6e 74 65 6e 74 |if (*(p-|>content|
|00001610| 73 29 20 21 3d 20 27 5c | 30 27 29 20 7b 0d 20 20 |s) != '\|0') {. |
|00001620| 20 20 69 66 20 28 2a 6c | 6f 63 66 6f 72 6d 61 74 | if (*l|ocformat|
|00001630| 29 20 7b 0d 20 20 20 20 | 20 20 20 20 69 66 20 28 |) {. | if (|
|00001640| 70 72 69 6e 74 6c 6f 63 | 28 6f 75 74 2c 6c 6f 63 |printloc|(out,loc|
|00001650| 66 6f 72 6d 61 74 2c 70 | 2d 3e 6c 6f 63 2c 70 61 |format,p|->loc,pa|
|00001660| 72 74 69 61 6c 5f 64 69 | 73 74 61 6e 63 65 29 20 |rtial_di|stance) |
|00001670| 26 26 20 28 70 20 21 3d | 20 6d 70 2d 3e 68 65 61 |&& (p !=| mp->hea|
|00001680| 64 29 29 0d 20 20 20 20 | 20 20 20 20 20 20 20 20 |d)). | |
|00001690| 20 20 69 6e 64 65 6e 74 | 5f 66 6f 72 28 70 61 72 | indent|_for(par|
|000016a0| 74 69 61 6c 5f 64 69 73 | 74 61 6e 63 65 2c 20 6f |tial_dis|tance, o|
|000016b0| 75 74 29 3b 0d 20 20 20 | 20 7d 20 65 6c 73 65 20 |ut);. | } else |
|000016c0| 69 66 20 28 70 61 72 74 | 69 61 6c 5f 64 69 73 74 |if (part|ial_dist|
|000016d0| 61 6e 63 65 20 3d 3d 20 | 30 29 20 7b 0d 20 20 20 |ance == |0) {. |
|000016e0| 20 20 20 20 20 69 6e 64 | 65 6e 74 5f 66 6f 72 28 | ind|ent_for(|
|000016f0| 69 6e 64 65 6e 74 2c 20 | 6f 75 74 29 3b 0d 20 20 |indent, |out);. |
|00001700| 20 20 20 20 20 20 70 61 | 72 74 69 61 6c 5f 64 69 | pa|rtial_di|
|00001710| 73 74 61 6e 63 65 20 3d | 20 69 6e 64 65 6e 74 3b |stance =| indent;|
|00001720| 0d 20 20 20 20 7d 0d 20 | 20 20 20 66 70 72 69 6e |. }. | fprin|
|00001730| 74 66 28 6f 75 74 2c 22 | 25 73 22 2c 70 2d 3e 63 |tf(out,"|%s",p->c|
|00001740| 6f 6e 74 65 6e 74 73 29 | 3b 0d 20 20 20 20 70 61 |ontents)|;. pa|
|00001750| 72 74 69 61 6c 5f 64 69 | 73 74 61 6e 63 65 20 3d |rtial_di|stance =|
|00001760| 20 6c 69 6d 69 74 63 6f | 6c 75 6d 6e 28 70 2d 3e | limitco|lumn(p->|
|00001770| 63 6f 6e 74 65 6e 74 73 | 2c 20 70 61 72 74 69 61 |contents|, partia|
|00001780| 6c 5f 64 69 73 74 61 6e | 63 65 29 3b 0d 7d 0d 3c |l_distan|ce);.}.<|
|00001790| 3c 70 72 69 6e 74 20 61 | 20 6e 65 77 6c 69 6e 65 |<print a| newline|
|000017a0| 3e 3e 3d 0d 70 61 72 74 | 69 61 6c 5f 64 69 73 74 |>>=.part|ial_dist|
|000017b0| 61 6e 63 65 20 3d 20 30 | 3b 0d 70 75 74 63 28 27 |ance = 0|;.putc('|
|000017c0| 5c 6e 27 2c 20 6f 75 74 | 29 3b 0d 6c 61 73 74 6c |\n', out|);.lastl|
|000017d0| 69 6e 65 6e 6f 2b 2b 3b | 0d 40 0d 57 68 65 6e 20 |ineno++;|.@.When |
|000017e0| 77 65 27 72 65 20 65 78 | 70 61 6e 64 69 6e 67 20 |we're ex|panding |
|000017f0| 61 20 6d 6f 64 75 6c 65 | 2c 20 74 68 65 20 70 61 |a module|, the pa|
|00001800| 72 74 69 61 6c 20 64 69 | 73 74 61 6e 63 65 20 62 |rtial di|stance b|
|00001810| 65 63 6f 6d 65 73 20 74 | 68 65 20 6e 65 77 20 69 |ecomes t|he new i|
|00001820| 6e 64 65 6e 74 61 74 69 | 6f 6e 20 6c 65 76 65 6c |ndentati|on level|
|00001830| 2e 0d 3c 3c 65 78 70 61 | 6e 64 20 61 20 6d 6f 64 |..<<expa|nd a mod|
|00001840| 75 6c 65 3e 3e 3d 0d 6e | 65 77 6d 6f 64 20 3d 20 |ule>>=.n|ewmod = |
|00001850| 6c 6f 6f 6b 75 70 28 70 | 2d 3e 63 6f 6e 74 65 6e |lookup(p|->conten|
|00001860| 74 73 29 3b 0d 69 66 20 | 28 6e 65 77 6d 6f 64 3d |ts);.if |(newmod=|
|00001870| 3d 4e 55 4c 4c 29 20 7b | 0d 20 20 20 20 65 72 72 |=NULL) {|. err|
|00001880| 6f 72 6d 73 67 20 28 45 | 72 72 6f 72 2c 20 22 75 |ormsg (E|rror, "u|
|00001890| 6e 64 65 66 69 6e 65 64 | 20 6d 6f 64 75 6c 65 20 |ndefined| module |
|000018a0| 6e 61 6d 65 3a 20 40 3c | 3c 25 73 40 3e 3e 22 2c |name: @<|<%s@>>",|
|000018b0| 20 70 2d 3e 63 6f 6e 74 | 65 6e 74 73 29 3b 0d 20 | p->cont|ents);. |
|000018c0| 20 20 20 65 72 72 6f 72 | 3d 45 72 72 6f 72 3b 0d | error|=Error;.|
|000018d0| 7d 20 65 6c 73 65 20 7b | 0d 20 20 20 20 69 6e 74 |} else {|. int|
|000018e0| 20 72 65 74 63 6f 64 65 | 3b 0d 20 20 20 20 72 65 | retcode|;. re|
|000018f0| 74 63 6f 64 65 20 3d 20 | 65 78 70 61 6e 64 20 28 |tcode = |expand (|
|00001900| 6e 65 77 6d 6f 64 2c 20 | 70 61 72 74 69 61 6c 5f |newmod, |partial_|
|00001910| 64 69 73 74 61 6e 63 65 | 2c 20 70 61 72 74 69 61 |distance|, partia|
|00001920| 6c 5f 64 69 73 74 61 6e | 63 65 2c 0d 20 20 20 20 |l_distan|ce,. |
|00001930| 09 09 20 20 20 20 20 20 | 26 74 68 69 73 6d 6f 64 |.. |&thismod|
|00001940| 75 6c 65 2c 20 6c 6f 63 | 66 6f 72 6d 61 74 2c 20 |ule, loc|format, |
|00001950| 6f 75 74 29 3b 0d 20 20 | 20 20 69 66 20 28 72 65 |out);. | if (re|
|00001960| 74 63 6f 64 65 20 3e 20 | 65 72 72 6f 72 29 20 65 |tcode > |error) e|
|00001970| 72 72 6f 72 20 3d 20 72 | 65 74 63 6f 64 65 3b 0d |rror = r|etcode;.|
|00001980| 7d 0d 70 61 72 74 69 61 | 6c 5f 64 69 73 74 61 6e |}.partia|l_distan|
|00001990| 63 65 20 3d 20 6c 69 6d | 69 74 63 6f 6c 75 6d 6e |ce = lim|itcolumn|
|000019a0| 28 70 2d 3e 63 6f 6e 74 | 65 6e 74 73 2c 20 70 61 |(p->cont|ents, pa|
|000019b0| 72 74 69 61 6c 5f 64 69 | 73 74 61 6e 63 65 20 2b |rtial_di|stance +|
|000019c0| 20 32 29 20 2b 20 32 3b | 20 0d 09 09 09 09 2f 2a | 2) + 2;| ...../*|
|000019d0| 20 61 63 63 6f 75 6e 74 | 20 66 6f 72 20 73 75 72 | account| for sur|
|000019e0| 72 6f 75 6e 64 69 6e 67 | 20 62 72 61 63 6b 65 74 |rounding| bracket|
|000019f0| 73 20 2a 2f 0d 40 0d 3c | 3c 69 66 20 5b 5b 6d 70 |s */.@.<|<if [[mp|
|00001a00| 5d 5d 20 69 73 20 61 6e | 20 61 6e 63 65 73 74 6f |]] is an| ancesto|
|00001a10| 72 2c 20 63 6f 6d 70 6c | 61 69 6e 20 61 6e 64 20 |r, compl|ain and |
|00001a20| 72 65 74 75 72 6e 3e 3e | 3d 0d 69 66 20 28 73 65 |return>>|=.if (se|
|00001a30| 65 6b 63 79 63 6c 65 28 | 6d 70 2c 20 70 61 72 65 |ekcycle(|mp, pare|
|00001a40| 6e 74 29 29 20 7b 0d 20 | 20 20 20 65 72 72 6f 72 |nt)) {. | error|
|00001a50| 6d 73 67 28 45 72 72 6f | 72 2c 20 22 40 3c 3c 25 |msg(Erro|r, "@<<%|
|00001a60| 73 40 3e 3e 22 2c 20 6d | 70 2d 3e 6e 61 6d 65 29 |s@>>", m|p->name)|
|00001a70| 3b 0d 20 20 20 20 72 65 | 74 75 72 6e 20 45 72 72 |;. re|turn Err|
|00001a80| 6f 72 3b 0d 7d 0d 3c 3c | 46 75 6e 63 74 69 6f 6e |or;.}.<<|Function|
|00001a90| 20 64 65 63 6c 61 72 61 | 74 69 6f 6e 73 3e 3e 3d | declara|tions>>=|
|00001aa0| 0d 73 74 61 74 69 63 20 | 69 6e 74 20 73 65 65 6b |.static |int seek|
|00001ab0| 63 79 63 6c 65 28 4d 6f | 64 75 6c 65 20 6d 70 2c |cycle(Mo|dule mp,|
|00001ac0| 20 50 61 72 65 6e 74 20 | 70 61 72 65 6e 74 29 3b | Parent |parent);|
|00001ad0| 0d 3c 3c 43 20 66 75 6e | 63 74 69 6f 6e 73 3e 3e |.<<C fun|ctions>>|
|00001ae0| 3d 0d 73 74 61 74 69 63 | 20 69 6e 74 20 73 65 65 |=.static| int see|
|00001af0| 6b 63 79 63 6c 65 28 4d | 6f 64 75 6c 65 20 6d 70 |kcycle(M|odule mp|
|00001b00| 2c 20 50 61 72 65 6e 74 | 20 70 61 72 65 6e 74 29 |, Parent| parent)|
|00001b10| 20 7b 0d 20 20 20 20 69 | 66 20 28 70 61 72 65 6e | {. i|f (paren|
|00001b20| 74 20 3d 3d 20 4e 55 4c | 4c 29 20 7b 0d 20 20 20 |t == NUL|L) {. |
|00001b30| 20 20 20 20 20 72 65 74 | 75 72 6e 20 30 3b 0d 20 | ret|urn 0;. |
|00001b40| 20 20 20 7d 20 65 6c 73 | 65 20 69 66 20 28 70 61 | } els|e if (pa|
|00001b50| 72 65 6e 74 2d 3e 74 68 | 69 73 20 3d 3d 20 6d 70 |rent->th|is == mp|
|00001b60| 20 7c 7c 20 73 65 65 6b | 63 79 63 6c 65 28 6d 70 | || seek|cycle(mp|
|00001b70| 2c 20 70 61 72 65 6e 74 | 2d 3e 70 61 72 65 6e 74 |, parent|->parent|
|00001b80| 29 29 20 7b 0d 20 20 20 | 20 20 20 20 20 69 66 20 |)) {. | if |
|00001b90| 28 70 61 72 65 6e 74 2d | 3e 74 68 69 73 20 3d 3d |(parent-|>this ==|
|00001ba0| 20 6d 70 29 0d 20 20 20 | 20 20 20 20 20 20 20 20 | mp). | |
|00001bb0| 20 66 70 72 69 6e 74 66 | 28 73 74 64 65 72 72 2c | fprintf|(stderr,|
|00001bc0| 20 22 43 79 63 6c 69 63 | 20 63 6f 64 65 20 63 68 | "Cyclic| code ch|
|00001bd0| 75 6e 6b 73 3a 20 22 29 | 3b 0d 20 20 20 20 20 20 |unks: ")|;. |
|00001be0| 20 20 66 70 72 69 6e 74 | 66 28 73 74 64 65 72 72 | fprint|f(stderr|
|00001bf0| 2c 20 22 40 3c 3c 25 73 | 40 3e 3e 20 2d 3e 20 22 |, "@<<%s|@>> -> "|
|00001c00| 2c 20 70 61 72 65 6e 74 | 2d 3e 74 68 69 73 2d 3e |, parent|->this->|
|00001c10| 6e 61 6d 65 29 3b 0d 20 | 20 20 20 20 20 20 20 72 |name);. | r|
|00001c20| 65 74 75 72 6e 20 31 3b | 0d 20 20 20 20 7d 20 65 |eturn 1;|. } e|
|00001c30| 6c 73 65 20 7b 0d 20 20 | 20 20 20 20 20 20 72 65 |lse {. | re|
|00001c40| 74 75 72 6e 20 30 3b 0d | 20 20 20 20 7d 0d 7d 0d |turn 0;.| }.}.|
|00001c50| 40 20 25 64 65 66 20 73 | 65 65 6b 63 79 63 6c 65 |@ %def s|eekcycle|
|00001c60| 0d 0d 50 72 69 6e 74 69 | 6e 67 20 6c 6f 63 61 74 |..Printi|ng locat|
|00001c70| 69 6f 6e 73 20 6d 65 61 | 6e 73 20 65 6d 69 74 74 |ions mea|ns emitt|
|00001c80| 69 6e 67 20 5b 5b 23 6c | 69 6e 65 5d 5d 20 6e 75 |ing [[#l|ine]] nu|
|00001c90| 6d 62 65 72 73 2e 0d 5b | 5b 70 72 69 6e 74 6c 6f |mbers..[|[printlo|
|00001ca0| 63 5d 5d 20 65 6d 69 74 | 73 20 61 20 5b 5b 23 6c |c]] emit|s a [[#l|
|00001cb0| 69 6e 65 5d 5d 20 6f 6e | 6c 79 20 69 66 20 74 68 |ine]] on|ly if th|
|00001cc0| 65 20 6c 69 6e 65 20 65 | 6d 69 74 74 65 64 20 69 |e line e|mitted i|
|00001cd0| 73 20 6f 75 74 20 6f 66 | 20 73 65 71 75 65 6e 63 |s out of| sequenc|
|00001ce0| 65 2e 0d 49 74 20 72 65 | 74 75 72 6e 73 20 6e 6f |e..It re|turns no|
|00001cf0| 6e 7a 65 72 6f 20 77 68 | 65 6e 20 5b 5b 23 6c 69 |nzero wh|en [[#li|
|00001d00| 6e 65 5d 5d 20 69 73 20 | 65 6d 69 74 74 65 64 3b |ne]] is |emitted;|
|00001d10| 20 7a 65 72 6f 20 6f 74 | 68 65 72 77 69 73 65 2e | zero ot|herwise.|
|00001d20| 0d 54 68 65 20 66 6c 61 | 67 20 5b 5b 70 61 72 74 |.The fla|g [[part|
|00001d30| 69 61 6c 5d 5d 20 74 65 | 6c 6c 73 20 77 68 65 74 |ial]] te|lls whet|
|00001d40| 68 65 72 20 74 68 65 20 | 70 72 65 63 65 64 69 6e |her the |precedin|
|00001d50| 67 20 6c 69 6e 65 20 77 | 61 73 20 70 61 72 74 69 |g line w|as parti|
|00001d60| 61 6c 2e 0d 49 66 20 73 | 6f 2c 20 74 68 65 6e 20 |al..If s|o, then |
|00001d70| 61 20 6e 65 77 6c 69 6e | 65 20 69 73 20 6e 65 63 |a newlin|e is nec|
|00001d80| 65 73 73 61 72 79 20 62 | 65 66 6f 72 65 20 5b 5b |essary b|efore [[|
|00001d90| 23 6c 69 6e 65 5d 5d 20 | 63 61 6e 20 62 65 20 65 |#line]] |can be e|
|00001da0| 6d 69 74 74 65 64 2e 0d | 3c 3c 68 65 61 64 65 72 |mitted..|<<header|
|00001db0| 3e 3e 3d 0d 69 6e 74 20 | 70 72 69 6e 74 6c 6f 63 |>>=.int |printloc|
|00001dc0| 28 46 49 4c 45 20 2a 66 | 70 2c 20 63 68 61 72 20 |(FILE *f|p, char |
|00001dd0| 2a 66 6d 74 2c 20 4c 6f | 63 61 74 69 6f 6e 20 6c |*fmt, Lo|cation l|
|00001de0| 6f 63 2c 20 69 6e 74 20 | 70 61 72 74 69 61 6c 29 |oc, int |partial)|
|00001df0| 3b 0d 3c 3c 43 20 66 75 | 6e 63 74 69 6f 6e 73 3e |;.<<C fu|nctions>|
|00001e00| 3e 3d 0d 69 6e 74 20 70 | 72 69 6e 74 6c 6f 63 28 |>=.int p|rintloc(|
|00001e10| 46 49 4c 45 20 2a 66 70 | 2c 20 63 68 61 72 20 2a |FILE *fp|, char *|
|00001e20| 66 6d 74 2c 20 4c 6f 63 | 61 74 69 6f 6e 20 6c 6f |fmt, Loc|ation lo|
|00001e30| 63 2c 20 69 6e 74 20 70 | 61 72 74 69 61 6c 29 20 |c, int p|artial) |
|00001e40| 7b 0d 20 20 20 20 63 68 | 61 72 20 2a 70 3b 0d 20 |{. ch|ar *p;. |
|00001e50| 20 20 20 69 66 20 28 2a | 66 6d 74 0d 20 20 20 20 | if (*|fmt. |
|00001e60| 26 26 20 28 6c 6f 63 2e | 66 69 6c 65 6e 61 6d 65 |&& (loc.|filename|
|00001e70| 21 3d 6c 61 73 74 66 69 | 6c 65 6e 61 6d 65 20 7c |!=lastfi|lename ||
|00001e80| 7c 20 6c 61 73 74 6c 69 | 6e 65 6e 6f 20 21 3d 20 || lastli|neno != |
|00001e90| 6c 6f 63 2e 6c 69 6e 65 | 6e 6f 29 29 20 7b 0d 20 |loc.line|no)) {. |
|00001ea0| 20 20 20 20 20 20 20 69 | 66 20 28 70 61 72 74 69 | i|f (parti|
|00001eb0| 61 6c 29 20 70 75 74 63 | 28 27 5c 6e 27 2c 66 70 |al) putc|('\n',fp|
|00001ec0| 29 3b 0d 20 20 20 20 20 | 20 20 20 3c 3c 77 72 69 |);. | <<wri|
|00001ed0| 74 65 20 6f 75 74 20 74 | 68 65 20 6c 69 6e 65 20 |te out t|he line |
|00001ee0| 6e 75 6d 62 65 72 20 70 | 72 61 67 6d 61 3e 3e 0d |number p|ragma>>.|
|00001ef0| 20 20 20 20 20 20 20 20 | 6c 61 73 74 66 69 6c 65 | |lastfile|
|00001f00| 6e 61 6d 65 20 3d 20 6c | 6f 63 2e 66 69 6c 65 6e |name = l|oc.filen|
|00001f10| 61 6d 65 3b 0d 20 20 20 | 20 20 20 20 20 6c 61 73 |ame;. | las|
|00001f20| 74 6c 69 6e 65 6e 6f 20 | 3d 20 6c 6f 63 2e 6c 69 |tlineno |= loc.li|
|00001f30| 6e 65 6e 6f 3b 0d 20 20 | 20 20 20 20 20 20 72 65 |neno;. | re|
|00001f40| 74 75 72 6e 20 31 3b 0d | 20 20 20 20 7d 20 65 6c |turn 1;.| } el|
|00001f50| 73 65 20 72 65 74 75 72 | 6e 20 30 3b 0d 7d 0d 40 |se retur|n 0;.}.@|
|00001f60| 20 25 64 65 66 20 70 72 | 69 6e 74 6c 6f 63 0d 3c | %def pr|intloc.<|
|00001f70| 3c 77 72 69 74 65 20 6f | 75 74 20 74 68 65 20 6c |<write o|ut the l|
|00001f80| 69 6e 65 20 6e 75 6d 62 | 65 72 20 70 72 61 67 6d |ine numb|er pragm|
|00001f90| 61 3e 3e 3d 0d 66 6f 72 | 20 28 70 20 3d 20 66 6d |a>>=.for| (p = fm|
|00001fa0| 74 3b 20 2a 70 3b 20 70 | 2b 2b 29 20 7b 0d 20 20 |t; *p; p|++) {. |
|00001fb0| 20 20 69 66 20 28 2a 70 | 20 3d 3d 20 27 25 27 29 | if (*p| == '%')|
|00001fc0| 20 7b 0d 20 20 20 20 20 | 20 20 20 73 77 69 74 63 | {. | switc|
|00001fd0| 68 20 28 2a 2b 2b 70 29 | 20 7b 0d 20 20 20 20 20 |h (*++p)| {. |
|00001fe0| 20 20 20 20 20 20 20 63 | 61 73 65 20 27 25 27 3a | c|ase '%':|
|00001ff0| 20 70 75 74 63 28 27 25 | 27 2c 20 66 70 29 3b 20 | putc('%|', fp); |
|00002000| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002010| 20 20 20 20 20 20 20 20 | 20 20 20 20 62 72 65 61 | | brea|
|00002020| 6b 3b 0d 20 20 20 20 20 | 20 20 20 20 20 20 20 63 |k;. | c|
|00002030| 61 73 65 20 27 4e 27 3a | 20 70 75 74 63 28 27 5c |ase 'N':| putc('\|
|00002040| 6e 27 2c 20 66 70 29 3b | 20 20 20 20 20 20 20 20 |n', fp);| |
|00002050| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002060| 20 20 20 20 62 72 65 61 | 6b 3b 0d 20 20 20 20 20 | brea|k;. |
|00002070| 20 20 20 20 20 20 20 63 | 61 73 65 20 27 46 27 3a | c|ase 'F':|
|00002080| 20 66 70 72 69 6e 74 66 | 28 66 70 2c 20 22 25 73 | fprintf|(fp, "%s|
|00002090| 22 2c 20 6c 6f 63 2e 66 | 69 6c 65 6e 61 6d 65 29 |", loc.f|ilename)|
|000020a0| 3b 20 20 20 20 20 20 20 | 20 20 20 20 62 72 65 61 |; | brea|
|000020b0| 6b 3b 0d 20 20 20 20 20 | 20 20 20 20 20 20 20 63 |k;. | c|
|000020c0| 61 73 65 20 27 4c 27 3a | 20 66 70 72 69 6e 74 66 |ase 'L':| fprintf|
|000020d0| 28 66 70 2c 20 22 25 64 | 22 2c 20 6c 6f 63 2e 6c |(fp, "%d|", loc.l|
|000020e0| 69 6e 65 6e 6f 29 3b 20 | 20 20 20 20 20 20 20 20 |ineno); | |
|000020f0| 20 20 20 20 62 72 65 61 | 6b 3b 0d 20 20 20 20 20 | brea|k;. |
|00002100| 20 20 20 20 20 20 20 63 | 61 73 65 20 27 2d 27 3a | c|ase '-':|
|00002110| 20 63 61 73 65 20 27 2b | 27 3a 20 0d 20 20 20 20 | case '+|': . |
|00002120| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002130| 20 20 20 20 69 66 20 28 | 69 73 64 69 67 69 74 28 | if (|isdigit(|
|00002140| 70 5b 31 5d 29 20 26 26 | 20 70 5b 32 5d 20 3d 3d |p[1]) &&| p[2] ==|
|00002150| 20 27 4c 27 29 20 7b 0d | 20 20 20 20 20 20 20 20 | 'L') {.| |
|00002160| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002170| 20 20 66 70 72 69 6e 74 | 66 28 66 70 2c 20 22 25 | fprint|f(fp, "%|
|00002180| 64 22 2c 20 2a 70 20 3d | 3d 20 27 2b 27 20 3f 20 |d", *p =|= '+' ? |
|00002190| 6c 6f 63 2e 6c 69 6e 65 | 6e 6f 20 2b 20 28 70 5b |loc.line|no + (p[|
|000021a0| 31 5d 20 2d 20 27 30 27 | 29 0d 20 20 20 20 20 20 |1] - '0'|). |
|000021b0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000021c0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000021d0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000021e0| 3a 20 6c 6f 63 2e 6c 69 | 6e 65 6e 6f 20 2d 20 28 |: loc.li|neno - (|
|000021f0| 70 5b 31 5d 20 2d 20 27 | 30 27 29 29 3b 0d 20 20 |p[1] - '|0'));. |
|00002200| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002210| 20 20 20 20 20 20 20 20 | 70 20 2b 3d 20 32 3b 0d | |p += 2;.|
|00002220| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002230| 20 20 20 20 20 20 20 20 | 7d 20 65 6c 73 65 0d 20 | |} else. |
|00002240| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002250| 20 20 20 20 20 20 20 20 | 20 3c 3c 63 6f 6d 70 6c | | <<compl|
|00002260| 61 69 6e 20 61 62 6f 75 | 74 20 62 61 64 20 66 6f |ain abou|t bad fo|
|00002270| 72 6d 61 74 20 63 68 61 | 72 61 63 74 65 72 3e 3e |rmat cha|racter>>|
|00002280| 0d 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |. | |
|00002290| 20 20 20 20 20 20 20 62 | 72 65 61 6b 3b 20 20 20 | b|reak; |
|000022a0| 20 20 20 20 20 20 20 20 | 20 0d 20 20 20 20 20 20 | | . |
|000022b0| 20 20 20 20 20 20 64 65 | 66 61 75 6c 74 3a 20 20 | de|fault: |
|000022c0| 3c 3c 63 6f 6d 70 6c 61 | 69 6e 20 61 62 6f 75 74 |<<compla|in about|
|000022d0| 20 62 61 64 20 66 6f 72 | 6d 61 74 20 63 68 61 72 | bad for|mat char|
|000022e0| 61 63 74 65 72 3e 3e 20 | 20 20 62 72 65 61 6b 3b |acter>> | break;|
|000022f0| 0d 20 20 20 20 20 20 20 | 20 7d 0d 20 20 20 20 7d |. | }. }|
|00002300| 20 65 6c 73 65 20 70 75 | 74 63 28 2a 70 2c 20 66 | else pu|tc(*p, f|
|00002310| 70 29 3b 0d 7d 0d 3c 3c | 63 6f 6d 70 6c 61 69 6e |p);.}.<<|complain|
|00002320| 20 61 62 6f 75 74 20 62 | 61 64 20 66 6f 72 6d 61 | about b|ad forma|
|00002330| 74 20 63 68 61 72 61 63 | 74 65 72 3e 3e 3d 0d 7b |t charac|ter>>=.{|
|00002340| 20 73 74 61 74 69 63 20 | 69 6e 74 20 63 6f 6d 70 | static |int comp|
|00002350| 6c 61 69 6e 65 64 20 3d | 20 30 3b 0d 20 20 69 66 |lained =| 0;. if|
|00002360| 20 28 21 63 6f 6d 70 6c | 61 69 6e 65 64 29 20 7b | (!compl|ained) {|
|00002370| 0d 20 20 20 20 65 72 72 | 6f 72 6d 73 67 28 45 72 |. err|ormsg(Er|
|00002380| 72 6f 72 2c 22 42 61 64 | 20 66 6f 72 6d 61 74 20 |ror,"Bad| format |
|00002390| 73 65 71 75 65 6e 63 65 | 20 60 60 25 25 25 63 27 |sequence| ``%%%c'|
|000023a0| 27 20 69 6e 20 2d 4c 25 | 73 22 2c 2a 70 2c 66 6d |' in -L%|s",*p,fm|
|000023b0| 74 29 3b 0d 20 20 20 20 | 63 6f 6d 70 6c 61 69 6e |t);. |complain|
|000023c0| 65 64 20 3d 20 31 3b 0d | 20 20 7d 0d 7d 0d 40 0d |ed = 1;.| }.}.@.|
|000023d0| 0d 5c 73 75 62 73 75 62 | 73 65 63 74 69 6f 6e 7b |.\subsub|section{|
|000023e0| 4f 74 68 65 72 20 6f 70 | 65 72 61 74 69 6f 6e 73 |Other op|erations|
|000023f0| 20 6f 6e 20 63 6f 6d 70 | 6c 65 74 65 64 20 6d 6f | on comp|leted mo|
|00002400| 64 75 6c 65 73 7d 0d 46 | 6f 72 20 6d 6f 72 65 20 |dules}.F|or more |
|00002410| 65 6c 65 67 61 6e 74 2d | 6c 6f 6f 6b 69 6e 67 20 |elegant-|looking |
|00002420| 6f 75 74 70 75 74 2c 20 | 77 65 20 70 72 6f 76 69 |output, |we provi|
|00002430| 64 65 20 61 20 70 72 69 | 6d 69 74 69 76 65 20 74 |de a pri|mitive t|
|00002440| 68 61 74 20 72 65 6d 6f | 76 65 73 0d 74 68 65 20 |hat remo|ves.the |
|00002450| 66 69 6e 61 6c 20 6e 65 | 77 6c 69 6e 65 20 66 72 |final ne|wline fr|
|00002460| 6f 6d 20 61 20 6d 6f 64 | 75 6c 65 2e 0d 0d 57 65 |om a mod|ule...We|
|00002470| 20 77 69 6c 6c 20 75 73 | 65 20 5b 5b 61 70 70 6c | will us|e [[appl|
|00002480| 79 5f 65 61 63 68 5f 6d | 6f 64 75 6c 65 5d 5d 20 |y_each_m|odule]] |
|00002490| 74 6f 20 72 65 6d 6f 76 | 65 20 74 72 61 69 6c 69 |to remov|e traili|
|000024a0| 6e 67 20 6e 65 77 6c 69 | 6e 65 73 0d 66 72 6f 6d |ng newli|nes.from|
|000024b0| 20 65 61 63 68 20 6d 6f | 64 75 6c 65 2e 0d 54 68 | each mo|dule..Th|
|000024c0| 69 73 20 73 65 72 76 65 | 73 20 74 77 6f 20 70 75 |is serve|s two pu|
|000024d0| 72 70 6f 73 65 73 3a 20 | 66 69 72 73 74 2c 20 6f |rposes: |first, o|
|000024e0| 75 72 20 6f 75 74 70 75 | 74 20 6c 6f 6f 6b 73 20 |ur outpu|t looks |
|000024f0| 6e 69 63 65 72 2c 20 61 | 6e 64 2c 20 73 65 63 6f |nicer, a|nd, seco|
|00002500| 6e 64 2c 0d 69 74 20 6d | 61 6b 65 73 20 69 74 20 |nd,.it m|akes it |
|00002510| 70 6f 73 73 69 62 6c 65 | 20 74 6f 20 64 65 66 69 |possible| to defi|
|00002520| 6e 65 20 61 20 6d 6f 64 | 75 6c 65 20 74 68 61 74 |ne a mod|ule that|
|00002530| 20 64 6f 65 73 6e 27 74 | 20 65 6e 64 20 77 69 74 | doesn't| end wit|
|00002540| 68 20 6e 65 77 6c 69 6e | 65 2e 0d 0d 41 73 20 74 |h newlin|e...As t|
|00002550| 68 65 79 20 61 72 65 20 | 72 65 61 64 20 69 6e 2c |hey are |read in,|
|00002560| 20 61 6c 6c 20 6d 6f 64 | 75 6c 65 73 20 65 6e 64 | all mod|ules end|
|00002570| 20 77 69 74 68 20 6e 65 | 77 6c 69 6e 65 2c 20 62 | with ne|wline, b|
|00002580| 79 20 64 65 66 69 6e 69 | 74 69 6f 6e 2e 25 0d 5c |y defini|tion.%.\|
|00002590| 66 6f 6f 74 6e 6f 74 65 | 7b 45 78 63 65 70 74 20 |footnote|{Except |
|000025a0| 6f 66 20 63 6f 75 72 73 | 65 20 69 66 20 74 68 69 |of cours|e if thi|
|000025b0| 73 20 69 6e 70 75 74 20 | 63 61 6d 65 20 66 72 6f |s input |came fro|
|000025c0| 6d 20 61 6e 20 75 6e 63 | 6f 72 72 65 63 74 65 64 |m an unc|orrected|
|000025d0| 20 6e 75 77 65 62 20 66 | 69 6c 65 2c 20 0d 69 6e | nuweb f|ile, .in|
|000025e0| 20 77 68 69 63 68 20 63 | 61 73 65 20 6d 6f 64 75 | which c|ase modu|
|000025f0| 6c 65 73 20 6e 65 65 64 | 6e 27 74 20 65 6e 64 20 |les need|n't end |
|00002600| 77 69 74 68 20 6e 65 77 | 6c 69 6e 65 73 2e 20 20 |with new|lines. |
|00002610| 45 76 65 6e 74 75 61 6c | 6c 79 20 6f 6e 65 20 68 |Eventual|ly one h|
|00002620| 6f 70 65 73 0d 49 27 6c | 6c 20 66 69 78 20 6e 75 |opes.I'l|l fix nu|
|00002630| 6d 61 72 6b 75 70 20 74 | 6f 20 69 6e 73 65 72 74 |markup t|o insert|
|00002640| 20 65 78 61 63 74 6c 79 | 20 74 68 65 20 6e 65 77 | exactly| the new|
|00002650| 6c 69 6e 65 73 20 74 68 | 61 74 20 77 6f 75 6c 64 |lines th|at would|
|00002660| 20 62 65 20 72 65 6d 6f | 76 65 64 20 68 65 72 65 | be remo|ved here|
|00002670| 2e 7d 0d 57 65 20 72 65 | 6d 6f 76 65 20 61 6c 6c |.}.We re|move all|
|00002680| 20 6f 66 20 74 68 65 20 | 74 72 61 69 6c 69 6e 67 | of the |trailing|
|00002690| 20 6e 65 77 6c 69 6e 65 | 73 2e 0d 3c 3c 68 65 61 | newline|s..<<hea|
|000026a0| 64 65 72 3e 3e 3d 0d 76 | 6f 69 64 20 72 65 6d 6f |der>>=.v|oid remo|
|000026b0| 76 65 5f 66 69 6e 61 6c | 5f 6e 65 77 6c 69 6e 65 |ve_final|_newline|
|000026c0| 20 28 4d 6f 64 75 6c 65 | 20 6d 70 29 3b 0d 20 20 | (Module| mp);. |
|000026d0| 20 20 20 20 20 20 2f 2a | 20 72 65 6d 6f 76 65 20 | /*| remove |
|000026e0| 74 72 61 69 6c 69 6e 67 | 20 6e 65 77 6c 69 6e 65 |trailing| newline|
|000026f0| 20 74 68 61 74 20 6d 75 | 73 74 20 62 65 20 69 6e | that mu|st be in|
|00002700| 20 6d 6f 64 75 6c 65 20 | 2a 2f 0d 3c 3c 43 20 66 | module |*/.<<C f|
|00002710| 75 6e 63 74 69 6f 6e 73 | 3e 3e 3d 0d 76 6f 69 64 |unctions|>>=.void|
|00002720| 20 72 65 6d 6f 76 65 5f | 66 69 6e 61 6c 5f 6e 65 | remove_|final_ne|
|00002730| 77 6c 69 6e 65 20 28 4d | 6f 64 75 6c 65 20 6d 70 |wline (M|odule mp|
|00002740| 29 20 7b 0d 20 20 20 20 | 20 20 20 20 2f 2a 20 72 |) {. | /* r|
|00002750| 65 6d 6f 76 65 20 74 72 | 61 69 6c 69 6e 67 20 6e |emove tr|ailing n|
|00002760| 65 77 6c 69 6e 65 20 74 | 68 61 74 20 6d 75 73 74 |ewline t|hat must|
|00002770| 20 62 65 20 69 6e 20 6d | 6f 64 75 6c 65 20 2a 2f | be in m|odule */|
|00002780| 0d 20 20 20 20 69 66 20 | 28 6d 70 2d 3e 74 61 69 |. if |(mp->tai|
|00002790| 6c 3d 3d 4e 55 4c 4c 29 | 20 2f 2a 20 6d 6f 64 75 |l==NULL)| /* modu|
|000027a0| 6c 65 20 68 61 73 20 6e | 6f 20 74 65 78 74 20 2a |le has n|o text *|
|000027b0| 2f 0d 20 20 20 20 20 20 | 20 20 72 65 74 75 72 6e |/. | return|
|000027c0| 3b 0d 20 20 20 20 69 66 | 20 28 6d 70 2d 3e 74 61 |;. if| (mp->ta|
|000027d0| 69 6c 2d 3e 70 74 79 70 | 65 20 21 3d 20 4e 45 57 |il->ptyp|e != NEW|
|000027e0| 4c 49 4e 45 29 0d 20 20 | 20 20 20 20 20 20 2f 2a |LINE). | /*|
|000027f0| 20 64 6f 20 6e 6f 74 68 | 69 6e 67 20 2d 2d 2d 20 | do noth|ing --- |
|00002800| 74 68 69 73 20 69 73 20 | 70 6f 73 73 69 62 6c 65 |this is |possible|
|00002810| 20 77 69 74 68 20 6e 75 | 77 65 62 20 66 72 6f 6e | with nu|web fron|
|00002820| 74 20 65 6e 64 0d 20 20 | 20 20 20 20 20 20 20 20 |t end. | |
|00002830| 20 20 20 20 66 6f 72 6d | 65 72 6c 79 3a 20 69 6d | form|erly: im|
|00002840| 70 6f 73 73 69 62 6c 65 | 28 22 4d 6f 64 75 6c 65 |possible|("Module|
|00002850| 20 64 6f 65 73 6e 27 74 | 20 65 6e 64 20 77 69 74 | doesn't| end wit|
|00002860| 68 20 6e 65 77 6c 69 6e | 65 22 29 3b 20 2a 2f 0d |h newlin|e"); */.|
|00002870| 20 20 20 20 20 20 20 20 | 3b 0d 20 20 20 20 65 6c | |;. el|
|00002880| 73 65 20 69 66 20 28 6d | 70 2d 3e 74 61 69 6c 20 |se if (m|p->tail |
|00002890| 3d 3d 20 6d 70 2d 3e 68 | 65 61 64 29 0d 09 20 20 |== mp->h|ead).. |
|000028a0| 20 20 6d 70 2d 3e 68 65 | 61 64 20 3d 20 6d 70 2d | mp->he|ad = mp-|
|000028b0| 3e 74 61 69 6c 20 3d 20 | 4e 55 4c 4c 3b 0d 20 20 |>tail = |NULL;. |
|000028c0| 20 20 65 6c 73 65 20 7b | 0d 09 73 74 72 75 63 74 | else {|..struct|
|000028d0| 20 6d 6f 64 70 61 72 74 | 20 2a 70 20 3d 20 6d 70 | modpart| *p = mp|
|000028e0| 2d 3e 68 65 61 64 3b 0d | 09 77 68 69 6c 65 20 28 |->head;.|.while (|
|000028f0| 70 2d 3e 6e 65 78 74 20 | 21 3d 20 6d 70 2d 3e 74 |p->next |!= mp->t|
|00002900| 61 69 6c 29 20 70 20 3d | 20 70 2d 3e 6e 65 78 74 |ail) p =| p->next|
|00002910| 3b 0d 20 20 20 20 20 20 | 20 20 70 2d 3e 6e 65 78 |;. | p->nex|
|00002920| 74 20 3d 20 4e 55 4c 4c | 3b 0d 20 20 20 20 7d 0d |t = NULL|;. }.|
|00002930| 7d 0d 40 20 25 64 65 66 | 20 72 65 6d 6f 76 65 5f |}.@ %def| remove_|
|00002940| 66 69 6e 61 6c 5f 6e 65 | 77 6c 69 6e 65 0d |final_ne|wline. |
+--------+-------------------------+-------------------------+--------+--------+